Number of days after which tank will become empty
Given a tank with capacity C liters which is completely filled in starting. Everyday tank is filled with l liters of water and in the case of overflow extra water is thrown out. Now on i-th day i liters of water is taken out for drinking. We need to find out the day at which tank will become empty the first time....
read more
Print last k digits of a^b (a raised to power b)
Given positive integers k, a and b we need to print last k digits of a^b ie.. pow(a, b)....
read more
Find the element that appears once in a sorted array
Given a sorted array in which all elements appear twice (one after one) and one element appears only once. Find that element in O(log n) complexity....
read more
Find minimum steps required to reach the end of a matrix | Set – 1
Given a 2D matrix consisting of positive integers, the task is to find the minimum number of steps required to reach the end(leftmost-bottom cell) of the matrix. If we are at cell (i, j) we can go to cells (i, j+arr[i][j]) or (i+arr[i][j], j). We can not go out of bounds. If no path exists, print -1....
read more
C# Program to Check for Majority Element in a sorted array
Problem Statement: Write a function to find if a given integer x appears more than n/2 times in a sorted array of n integers....
read more
Count number of pairs with the given Comparator
Given an array arr[], the task is to count the number of pairs (arr[i], arr[j]) on the right of every element with any custom comparator....
read more
Binary Search using pthread
Binary search is a popular method of searching in a sorted array or list. It simply divides the list into two halves and discards the half which has zero probability of having the key. On dividing, we check the midpoint for the key and use the lower half if the key is less than the midpoint and the upper half if the key is greater than the midpoint. Binary search has a time complexity of O(log(n)). Binary search can also be implemented using multi-threading where we utilize the cores of the processor by providing each thread a portion of the list to search for the key. The number of threads depends upon the number of cores your processor has and it’s better to create one thread for each core. Examples:...
read more
Minimum count of elements required to obtain the given Array by repeated mirror operations
Given an array arr[] consisting of N integers, the task is to find the array K[] of minimum possible length such that after performing multiple mirror operations on K[], the given array arr[] can be obtained....
read more
Range Queries for number of Armstrong numbers in an array with updates
Given an array arr[] of N integers, the task is to perform the following two queries:...
read more
Array Range Queries to find the Maximum Armstrong number with updates
Given an array arr[] of N integers, the task is to perform the following two queries:...
read more
Find the number of different numbers in the array after applying the given operation q times
Given an array of size N, initially consists of zeroes only. The task is to apply the given operation q times and find the number of different numbers in the array except for zeroes. Operation Format: update(l, r, x):: update a[i] = x for all (l <= i <= r)....
read more
Sum of all array elements less than X and greater than Y for Q queries
Given a sorted array arr[], and a set Q having M queries, where each query has values X and Y, the task is to find the sum of all integers less than X and greater than Y present in the array. Note: X and Y may or may not be present in the array....
read more